﻿<%@ Control Language="C#" ClassName="PhoneCategories" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<script runat="server">
	protected override void OnInit(EventArgs e) {
		base.OnInit(e);
		RadGrid1.DataBinding += new EventHandler(RadGrid1_DataBinding);
		ds.Selecting += new EventHandler<LinqDataSourceSelectEventArgs>(ds_Selecting);
	}

	void ds_Selecting(object sender, LinqDataSourceSelectEventArgs e) {
		
	}

	void RadGrid1_DataBinding(object sender, EventArgs e) {
	}
</script>

       <!-- content start -->
       <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
        <!--
        	var hasChanges, inputs, dropdowns, editedRow, isInsert;

        	function RowClick(sender, eventArgs) {
        		var gridTableView = $find("<%= RadGrid1.MasterTableView.ClientID %>");
        		if (editedRow && hasChanges) {
        			hasChanges = false;
        			if (confirm("Update changes?")) {

        				gridTableView.updateItem(editedRow);
        			}
        		}
        		if (editedRow) {
        			hasChanges = false;
        			gridTableView.cancelUpdate(editedRow);
        		}
        		if (isInsert) {
        			gridTableView.insertItem();
        		}
        	}

        	function RowDblClick(sender, eventArgs) {
        		editedRow = eventArgs.get_itemIndexHierarchical();
        		$find("<%= RadGrid1.MasterTableView.ClientID %>").editItem(editedRow);
        	}

        	function GridCommand(sender, args) {
        		var command = args.get_commandName();
        		if (command != "Edit") {
        			editedRow = null;
        		}
        		isInsert = command == "InitInsert";
        	}

        	function GridCreated(sender, eventArgs) {
        		var gridElement = sender.get_element();
        		var elementsToUse = [];
        		inputs = gridElement.getElementsByTagName("input");
        		for (var i = 0; i < inputs.length; i++) {
        			var lowerType = inputs[i].type.toLowerCase();
        			if (lowerType == "hidden" || lowerType == "button") {
        				continue;
        			}

        			Array.add(elementsToUse, inputs[i]);
        			inputs[i].onchange = TrackChanges;
        		}

        		dropdowns = gridElement.getElementsByTagName("select");
        		for (var i = 0; i < dropdowns.length; i++) {
        			dropdowns[i].onchange = TrackChanges;
        		}

        		setTimeout(function() { if (elementsToUse[0]) try { elementsToUse[0].focus(); } catch (e) { } }, 100);
        	}

        	function TrackChanges(e) {
        		hasChanges = true;
        	}
        	function showColumns() {
        		alert('DImok')
        	}
	    -->	
    </script>
   </telerik:RadCodeBlock>
       <telerik:RadAjaxManagerProxy ID="RadAjaxManager1" runat="server">
       <AjaxSettings>
				<telerik:AjaxSetting AjaxControlID="RadGrid1">
				<UpdatedControls>
					<telerik:AjaxUpdatedControl ControlID="RadGrid1" />
				</UpdatedControls>
				</telerik:AjaxSetting>
       </AjaxSettings>
       </telerik:RadAjaxManagerProxy>
       <UI:RadGridExtender ID="rge" TargetControlID="RadGrid1" runat1="server" />
<telerik:RadGrid DataSourceID="ds" ID="RadGrid1" runat="server" EnableEmbeddedSkins="true" AutoGenerateColumns="false"
	AllowFilteringByColumn="true" Skin="Office2007" EnableViewState="true" AllowPaging="true" PageSize="15"
	AllowAutomaticUpdates="true" AllowAutomaticInserts="true" AllowAutomaticDeletes="true">
	<MasterTableView FilterItemStyle-Width="95%" CommandItemDisplay="Bottom" Caption="Phone Categories" Width="0"
		ShowHeader="true" FilterItemStyle-Wrap="false" EditMode="InPlace" InsertItemDisplay="Bottom" DataKeyNames="ID"
		ClientDataKeyNames="ID" CommandItemSettings-AddNewRecordText="Add"
		ExpandCollapseColumn-Display="true" ExpandCollapseColumn-ButtonType="ImageButton" ExpandCollapseColumn-HeaderButtonType="PushButton"
		>
		<PagerStyle AlwaysVisible="true" HorizontalAlign="Left" Mode="Advanced" ShowPagerText="true" />
	<Columns>
		<telerik:GridClientDeleteColumn ButtonType="ImageButton" ConfirmText="Delete Record?" CommandName="Delete" ConfirmDialogType="Classic"></telerik:GridClientDeleteColumn>
		<telerik:GridEditCommandColumn ButtonType="ImageButton"></telerik:GridEditCommandColumn>
		<telerik:GridTemplateColumn DataField="Dimok" UniqueName="Dimok">
			<ItemTemplate>Dimok</ItemTemplate>
		</telerik:GridTemplateColumn>
	</Columns>
	</MasterTableView>
   <ClientSettings AllowColumnHide="true" AllowColumnsReorder="true"
			Resizing-AllowColumnResize="true" Resizing-ClipCellContentOnResize="true"
			Resizing-EnableRealTimeResize="true" Resizing-ResizeGridOnColumnResize="true" ReorderColumnsOnClient="true"
		>
        <ClientEvents OnRowClick="RowClick" OnRowDblClick="RowDblClick" OnColumnContextMenu="showColumns"
            OnGridCreated="GridCreated" OnCommand="GridCommand" />
   </ClientSettings>
</telerik:RadGrid>
<asp:LinqDataSource ID="ds" ContextTypeName="Data.LINQ.MotoBank" TableName="ts_PhoneCategories" runat="server"
		 EnableUpdate="true" EnableInsert="true" EnableDelete="true" />
